#include <iostream>
#include <string>
using namespace std;

string longestPalindrome(string s)
{
    bool dp[s.size()][s.size()];
    for (int i = 0; i < s.size(); ++i) {
	for (int j = 0; j < s.size(); ++j)
	    if (i == j) {
		dp[i][j] = 1;
	    } else {
		dp[i][j] = 0;
	    }
    }
    int maxbegin = -1;
    int maxend = -1;
    int maxlen = 0;
    for (int k = 1; k < s.size(); ++k) {
	for (int p = 0; p < k; ++p) {
	    bool temp1 = (p + 1 <= k - 1) ? (dp[p + 1][k - 1]) : (1);
	    if (temp1 == 1 && s[p] == s[k]) {
		if (k - p + 1 > maxlen) {
		    maxlen = k - p + 1;
		    maxbegin = p;
		    maxend = k;
		}
	    }
	}
    }
    return string(s.begin()+maxbegin,s.begin()+maxend);
}

int main()
{
}
